package com.jkoss.biz.imp.jy;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.jkoss.biz.jy.StucompanyBiz;
import com.jkoss.dao.jy.StucompanyMapper;
import com.jkoss.pojo.jy.Stucompany;
import com.jkoss.tool.Page;
@Component
public class StucompanyBizImpl  implements StucompanyBiz{
    
	@Autowired
	private StucompanyMapper ScDao;
	
	
	@Override
	public List<Stucompany> listPageSc(Page<Stucompany> page,Integer jyid, Integer eid) {
		if((jyid==null||jyid==0)&&(eid==null||eid==0)){
		return ScDao.listPageSc(page);
		}
		
		 Map<String, Object> params = new HashMap<String, Object>();
		 params.put("jyid", jyid);
		 params.put("eid", eid);
		 page.setParams(params);
		
		return ScDao.listPageByJyidAndEid(page);
	}


	@Override
	public Stucompany findById(Integer jygjID) {
		
		return ScDao.findById(jygjID);
	}


	@Override
	@Transactional
	public String addSc(Stucompany sc) {
		
		return ScDao.insert(sc)>0?"添加成功":"添加失败";
	}


	@Override
	@Transactional
	public String delSc(Integer jygjID) {
	
		return ScDao.deleteByPrimaryKey(jygjID)>0?"删除成功":"删除失败";
	}


	@Override
	@Transactional
	public String upSc(Stucompany sc) {
		
		return ScDao.updateByPrimaryKey(sc)>0?"更新成功":"更新失败";
	}


	@Override
	public Stucompany findByJyid(Integer jyid) {
		
		return ScDao.findByJyid(jyid);
	}

}
